//基本计算器
int calculate(char * s)
{
    int len=strlen(s);
    char sign='+';
    int stack[len];
    memset(stack,0,sizeof(int)*len);
    int top=-1;
    int num=0;
    for(int i=0;i<len;i++)
    {
       if (isdigit(s[i])) {
            num = num * 10 + (s[i] - '0'); 
        }
        if ((!isdigit(s[i]) && s[i] != ' ') || (i == len - 1)) {
            switch(sign) {
                case '+':
                    stack[++top] = num;
                    break;
                case '-':
                    stack[++top] = -num;
                    break;
                case '*':
                    num = stack[top--] * num;
                    stack[++top] = num;
                    break;
                case '/':
                    num = stack[top--] / num;
                    stack[++top] = num;
                    break;
            }
            sign = s[i];
            num = 0;
        }
    }

    int rst = 0;
    while (top > -1) {
        rst += stack[top--];
    }
    return rst;
}